﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Arizu.Repository;
using System.Data;

namespace AiRiZu.User
{
    public partial class WebForm1 : Common
    {
        public string TeSeimgurl = "images/default_user_pic.png";

        public string Xing { get; set; }

        public string Ming { get; set; }

        public string Email { get; set; }

        public string MobileTelephone { get; set; }

        public string Pass { get; set; }

        public int Sex { get; set; }

        public string School { get; set; }

        public string Adress { get; set; }

        public string Work { get; set; }

        public string TelephoneBack { get; set; }

        public string MyDesc { get; set; }

        public string TravelPlans { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            AirizuUser aUser = AirizuUser.CreateInstance();

            if (Session["logId"] == null)
            {
                return;
            }

            DataTable dt = aUser.GetUser(int.Parse(Session["logId"].ToString()));

            if (dt.Rows.Count > 0)
            {
                Xing = dt.Rows[0]["Xing"].ToString();
                Ming = dt.Rows[0]["Ming"].ToString();
                Email = dt.Rows[0]["Email"].ToString();
                MobileTelephone = dt.Rows[0]["MobileTelephone"].ToString();
                Pass = dt.Rows[0]["Pass"].ToString();
                Sex = int.Parse(dt.Rows[0]["Sex"].ToString());
                School = dt.Rows[0]["School"].ToString();
                Adress = dt.Rows[0]["Adress"].ToString();
                Work = dt.Rows[0]["Work"].ToString();
                TelephoneBack = dt.Rows[0]["TelephoneBack"].ToString();
                MyDesc = dt.Rows[0]["MyDesc"].ToString();
                TravelPlans = dt.Rows[0]["TravelPlans"].ToString();

                if (dt.Rows.Count > 0)
                {
                    if (string.IsNullOrEmpty(dt.Rows[0]["Image"].ToString()))
                    {
                        TeSeimgurl = "images/default_user_pic.png";
                    }
                    else
                    {
                        TeSeimgurl = Constants.IMGURL + dt.Rows[0]["Image"].ToString();
                    }
                }
            }
        }

        protected void Update(object sender, EventArgs e)
        {
            Session.Clear();

            string url = Request.Url.ToString().Replace("Edit.aspx", "Update.aspx");

            Response.Redirect(url);
        }

    }
}
